/**
 * 
 */
package com.yst.metho.web.application.components.listingview;

import nextapp.echo2.app.event.ActionEvent;

import com.yst.metho.web.application.interfaces.IListingViewModel;
import com.yst.metho.web.application.utils.ExceptionMgt;
import com.yst.suivi.data.rights.Right;

/**
 * Action qui permet de recharger les donnees contenues dans la table. Cette
 * action est generique a tous les composants.
 * 
 * @author perso
 * 
 */
public class RefreshToolbarAction extends ToolbarAction
{
	/**
	 * 
	 */
	private static final String BUTTON_ACTION_COMMAND = "RefreshClicked";

	private IListingViewModel mModel;

	public RefreshToolbarAction(IListingViewModel model)
	{
		super(Right.REFRESH, "Refresh");
		mModel = model;
		setActionCommand(BUTTON_ACTION_COMMAND);
		addActionListener(this);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.yst.metho.web.application.components.listingview.ToolbarAction#actionPerformed(nextapp.echo2.app.event.ActionEvent)
	 */
	public void actionPerformed(ActionEvent e)
	{
		if (BUTTON_ACTION_COMMAND.equals(e.getActionCommand()))
		{
			try
			{
				mModel.refresh();
			}
			catch (Throwable e1)
			{
				ExceptionMgt.manage(e1);
			}
		}
	}

}
